import Vue from 'vue'
import Vuex from 'vuex'
import {axioslink} from 'api/api.js'

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		homenav:[],
		upvipcourse:[],
		teachnav:[],
		bangong:[],
		carrernav:[],
		business:[],
		vipnav:[],
		assistnav:[],
		assnavList:[],
		minenav:[],
		courseNav:[]
	},
	mutations: {
		uphomenav(state,payload){
			state.homenav=payload;
		},
		upvipcourse(state,payload){
			state.upvipcourse=payload;
		},
		upteach(state,payload){
			state.teachnav=payload;
		},
		upbangong(state,payload){
			state.bangong=payload;
		},
		upcareer(state,payload){
			state.carrernav=payload;
		},
		upbusiness(state,payload){
			state.business=payload;
		},
		upvipnav(state,payload){
			state.vipnav=payload;
		},
		upassistnav(state,payload){
			state.assistnav=payload;
		},
		upassnavList(state,payload){
			state.assnavList=payload;
		},
		upminenav(state,payload){
			state.minenav=payload;
		},
		upcoursenav(state,payload){
			state.courseNav=payload;
		}
	},
	actions: {
		homenavaxios(context) {
			axioslink("/home/nav", "get").then((ok) => {
				context.commit("uphomenav",ok.data.arr)
			}).catch((err) => {
				console.log(err)
			})
		},
		vipcourseaxios(context){
			axioslink("/home/vipcourse", "get").then((ok) => {
				context.commit("upvipcourse",ok.data.arr)
			}).catch((err) => {
				console.log(err)
			})
		},
		teachaxios(context){
			axioslink("/home/teach", "get").then((ok) => {
				context.commit("upteach",ok.data.arr)
			}).catch((err) => {
				console.log(err)
			})
		},
		bangongaxios(context){
			axioslink("/home/bangong", "get").then((ok) => {
				context.commit("upbangong",ok.data.arr)
			}).catch((err) => {
				console.log(err)
			})
		},
		careeraxios(context){
			axioslink("/home/career", "get").then((ok) => {
				context.commit("upcareer",ok.data.arr)
			}).catch((err) => {
				console.log(err)
			})
		},
		businessaxios(context){
			axioslink("/home/business", "get").then((ok) => {
				context.commit("upbusiness",ok.data.arr)
			}).catch((err) => {
				console.log(err)
			})
		},
		vipnavaxios(context){
			axioslink("/vip/vipnav","get").then((ok)=>{
				context.commit("upvipnav",ok.data.arr)
			}).catch((err)=>{
				console.log(err);
			})
		},
		assistnavaxios(context){
			axioslink("/assist/assistnav","get").then((ok)=>{
				context.commit("upassistnav",ok.data.arr)
			}).catch((err)=>{
				console.log(err);
			})
		},
		assnavListaxios(context){
			axioslink("/assist/assistnavList","get").then((ok)=>{
				context.commit("upassnavList",ok.data.arr);
			}).catch((err)=>{
				console.log(err);
			})
		},
		minenavaxios(context){
			axioslink("/mine/minenav","get").then((ok)=>{
				console.log(ok);
				context.commit("upminenav",ok.data.arr);
			}).catch((err)=>{
				console.log(err);
			})
		},
		coursenavaxios(context){
			axioslink("/course/courseNavList","get").then((ok)=>{
				console.log(ok);
				context.commit("upcoursenav",ok.data.arr);
			}).catch((err)=>{
				console.log(err);
			})
		}
	},
	modules: {}
})
